﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Projeto_Alice___Forca
{
    class Botao
    {
        Texture2D t2dTextura;
        Rectangle rec1;
        Rectangle rec2;

        MouseState mouseAtual = Mouse.GetState();
        MouseState mouseAnterior = Mouse.GetState();

        public Botao(Texture2D t2dTextura, Rectangle rec1, Rectangle rec2)
        {
            this.t2dTextura = t2dTextura;
            this.rec1 = rec1;
            this.rec2 = rec2;
        }

        public void desenharBotao(SpriteBatch sprite)
        {
            if (Mouse.GetState().X > rec1.X &&
                Mouse.GetState().X < rec1.X + rec2.Width &&
                Mouse.GetState().Y > rec1.Y &&
                Mouse.GetState().Y < rec1.Y + rec2.Height)
                rec2.X = rec2.Width;
            else
                rec2.X = 0;

                sprite.Draw(t2dTextura, rec1, rec2, Color.White);
        }

        public bool checarClique()
        {
            bool checar = false;

            MouseState mouseAtual = Mouse.GetState();
            if (mouseAtual.X > rec1.X &&
                mouseAtual.X < rec1.X + t2dTextura.Width &&
                mouseAtual.Y > rec1.Y &&
                mouseAtual.Y < rec1.Y + t2dTextura.Height &&
                mouseAtual.LeftButton == ButtonState.Pressed &&
                mouseAnterior.LeftButton == ButtonState.Released)
            {
                checar = true;
            }

            mouseAnterior = mouseAtual;

            return checar;
        }
    }
}
